package apache;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.FastDateFormat;

/**
 * 日期工具类
 * @author steven
 *
 */
public class DateUtil {
	
	public static final String PATTERN = "yyyy-MM-dd";
	
	public static final String[] PATTERNS = {"yyyy-MM-dd","MM-dd"};
	
	public static final FastDateFormat fastDateFormat = FastDateFormat.getInstance(PATTERN);
	
	/**
	 * 获取起始日期startDate和结束日期endDate之间
	 * 的string类型的日期的列表
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public static List<String> getDays(Date startDate,Date endDate){
		List<String> result = new ArrayList<String>();
		return result;
	}
	/**
	 * 将字符串date转为Date类型
	 * @param date
	 * @throws ParseException 
	 */
	public static Date getDate(String date) throws ParseException{
		return DateUtils.parseDate(date, PATTERNS);
	}
	/**
	 * 将Date类型转为字符串
	 * @param date
	 * @return
	 */
	public static String getDate(Date date){
		return fastDateFormat.format(date);
	}
	/**
	 * 获取日期date前before天的日期
	 * @param date
	 * @param before
	 * @return
	 */
	public static Date getDateBefore(Date date,int before){
		return null;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(getDate(new Date(System.currentTimeMillis())));
	}

}
